public class Sort {

    public static void insertsort(int[] array) {
        int i = 1;
        while (i < array.length) {
            int j = i - 1;
            int tmp = array[i];
            while (j >= 0)
            if (array[j] > tmp) {
                array[j + 1] = array[j];
                j--;
            } else {
                break;
            }
            array[j + 1] = tmp;
            i++;
        }
    }

    public static void shellsort(int[] array) {
        int gap = array.length;
        while (gap > 1) {
            gap /= 2;
            shell(array, gap);
        }
    }

    public static void shell(int[] array, int gap) {
        int i = gap;
        while (i < array.length) {
            int j = i - gap;
            int tmp = array[i];
            while (j >= 0)
                if (array[j] > tmp) {
                    array[j + gap] = array[j];
                    j -= gap;
                } else {
                    break;
                }
            array[j + gap] = tmp;
            i++;
        }
    }
}


